package com.ruoyi.locksApi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
@ConditionalOnProperty(value = "spring.profiles.active", havingValue = "center", matchIfMissing = false)

@Component
public class LockCallbackInit {

    @Autowired
    private LockApiController lockApiController;

    @PostConstruct
    public void initCallback() {
        // 直接调用设置回调的接口（GET方式，使用配置文件里的默认回调地址）
        try {
            lockApiController.apartmentCallBackUrlSet();
            System.out.println("启动时已自动设置回调地址");
        } catch (Exception e) {
            System.err.println("启动时设置回调地址失败: " + e.getMessage());
        }
    }
}
